<!DOCTYPE html>
<html lang="zh">
<head>
    <meta charset="UTF-8">
    <title>一键以员工身份登录Confluence</title>
    <script>
        function loginAsEmp() {
            var empNo = document.getElementById("empNo").value;
            if (!empNo) {
                alert("请输入员工编号！");
                return;
            }
            // 获取后端Impersonation跳转链接
            fetch("http://localhost:8080/api/sso/impersonate?empNo=" + encodeURIComponent(empNo))
                .then(resp => resp.text())
                .then(url => {
                    // 新开窗口，激活SSO
                    let win = window.open(url, "_blank");
                    // 2秒后自动跳转到Confluence首页
                    setTimeout(function () {
                        win.location.href = "https://192.168.173.189/"; // 替换为你的Confluence实际地址
                    }, 2000);
                })
                .catch(err => {
                    alert("模拟登录失败：" + err);
                });
        }
    </script>
    <style>
        body { font-family: "Microsoft YaHei", Arial, sans-serif; background: #fafbfd; }
        .panel { background: #fff; border-radius: 8px; padding: 32px; max-width: 360px; margin: 100px auto; box-shadow: 0 8px 32px #0001; }
        input { width: 90%; padding: 10px; margin-bottom: 18px; border-radius: 4px; border: 1px solid #ccc; font-size: 16px; }
        button { width: 100%; padding: 12px; background: #206cff; color: #fff; font-size: 18px; border: none; border-radius: 4px; cursor: pointer;}
        button:hover { background: #085ac7; }
    </style>
</head>
<body>
<div class="panel">
    <h2>一键登录Confluence</h2>
    <input id="empNo" placeholder="请输入员工编号" autofocus />
    <button onclick="loginAsEmp()">以此员工编号登录并跳转</button>
    <div style="font-size:12px; color:#666; margin-top:18px;">
        首次登录会自动同步用户，无需手动注册
    </div>
</div>
</body>
</html>
